<%--
  Created by IntelliJ IDEA.
  User: Aaking-aline
  Date: 2022-05-23
  Time: 8:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>$Title$</title>
  </head>
  <body>
    <center>
      <form id="form1" action="LoginServlet">
        账号:<input type="text" id="username" name="username"> <br> <br>
        密码:<input type="text" id="password" name="password"> <br> <br>

        <input type="button" value="注册" onclick="dl()">
      </form>
    </center>
  </body>

  <script>
    function dl(){
      //-------------------------验证账号-------------------------------------------
      let usernameValue = document.getElementById("username").value;
      let usernameRegex = /(^\w+@\w+\.\w+$)|(^1[3578][0-9]{9}$)/;
      if(!usernameRegex.test(usernameValue)){
        alert("注册账号必须是邮箱或手机号");
        return;
      }
      //--------------------------验证密码------------------------------------------
      let passwordValue = document.getElementById("password").value;
      let passwordRegex = /^[0-9a-z]{4,15}$/;
      if(!passwordRegex.test(passwordValue)){
        alert("注册密码必须大于4位并且小于15位");
        return;
      }

      document.getElementById("form1").submit();
    }
  </script>



</html>
